package com.jxsd.edu.cn.struts2.daoImpl;

import com.jxsd.edu.cn.struts2.dao.StoreDao;
import com.jxsd.edu.cn.struts2.models.Pmsgstoreview;
import com.jxsd.edu.cn.tools.Page;
import com.jxsd.edu.cn.tools.PageBean;
import com.jxsd.edu.cn.tools.ResultBean;
import com.jxsd.edu.cn.tools.ResultList;
import com.jxsd.edu.cn.tools.StringTool;
import com.jxsd.edu.cn.tools.Template;

public class StoreDaoImpl implements StoreDao {
	 private    Template  t=new  Template();
	@Override
	public  void  addstore(Pmsgstoreview  store) {
		 String  sql="insert  into  pubmsgstore(userId,publishId,storeTime)   values(?,?,?)";
		   Object[]   params={store.getUserId(),store.getPublishId(),StringTool.getCurDate()};
		   t.update(sql, params);
	}

	@Override
	public   void  deletestore(String  publishId){
		String   sql="delete  from  pubmsgstore   where  publishId=?";
		 Object[]   params={publishId};
		 t.update(sql, params);
	}

	@Override
	public Page<Pmsgstoreview> getPersonStores(
			PageBean<Pmsgstoreview> pagebean, String userId) {
		String  sql="select  title,nickname,userId,publishId,storeTime   from   pmsgstoreview  where  userId=?  ";
		Object[]  params={userId};
        ResultList<Pmsgstoreview>	  hander=new  	ResultList<Pmsgstoreview>();
        Page<Pmsgstoreview>  page=null;
        try {
			page=hander.pageHandler(pagebean, sql, params, Pmsgstoreview.class);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return page;
	}

	@Override
	public Pmsgstoreview getPmsgstore(String publishId) 
	{
		String   sql="select  title,nickname,userId,publishId,storeTime   from   pmsgstoreview   where  publishId=?";
		Object[]  params={publishId};
		ResultBean<Pmsgstoreview>  hander=new  ResultBean<Pmsgstoreview>();
		Pmsgstoreview  view=null;
		try {
			view=hander.handler(sql, params, Pmsgstoreview.class);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return view;
	}

}
